home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-04-08 | 21.6 KB | 1,223 lines |
- head 1.8;
- branch ;
- access ;
- symbols patch1:1.8;
- locks ; strict;
- comment @ * @;
-
-
- 1.8
- date 88.07.31.18.50.56; author hyc; state Exp;
- branches ;
- next 1.7;
-
- 1.7
- date 88.06.12.19.23.13; author hyc; state Exp;
- branches ;
- next 1.6;
-
- 1.6
- date 88.06.12.18.47.09; author hyc; state Exp;
- branches ;
- next 1.5;
-
- 1.5
- date 88.06.01.19.41.20; author hyc; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 88.06.01.16.06.37; author hyc; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.06.01.15.54.35; author hyc; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.04.11.18.26.38; author hyc; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.04.11.18.21.31; author hyc; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.8
- log
- @Fix declarations, add memset() for BSD, removed a few revisions back.
- Fix args to fopen.
- @
- text
- @/*
- * Miscellaneous routines to get ARC running on non-MSDOS systems...
- * $Header: arcmisc.c,v 1.7 88/06/12 19:23:13 hyc Locked $
- */
-
- #include <stdio.h>
- #include <ctype.h>
- #include "arc.h"
-
- #if MSDOS
- #include <dir.h>
- #include <stat.h>
- #endif
-
- #if GEMDOS
- #include <osbind.h>
- #include <stat.h>
- char *index(), *rindex();
-
- void
- exitpause()
- {
- while (Cconis())
- Cnecin();
- fprintf(stderr, "Press any key to continue: ");
- fflush(stderr);
- Cnecin();
- fprintf(stderr, "\n");
- }
-
- int
- chdir(dirname)
- char *dirname;
- {
- char *i;
- int drv;
-
- i = dirname;
- if ((i = index(dirname, ':')) != NULL) {
- drv = i[-1];
- i++; /* Move past device spec */
- if (drv > '\'')
- drv -= 'a';
- else
- drv -= 'A';
- if (drv >= 0 && drv < 16)
- Dsetdrv(drv);
- }
- if (*i != '\0')
- return (Dsetpath(i));
- }
- #endif
-
- #if UNIX
- #include <sys/types.h>
- #include <sys/dir.h>
- #include <sys/stat.h>
- int rename(), unlink();
- #endif
-
- #if SYSV
- #include <dirent.h>
- #define DIRECT dirent
- #else
- #define DIRECT direct
- #endif
-
- #if BSD
- char *
- memset(s, c, n) /* oops. Thought it was standard BSD, but my Sun */
- char *s; /* fooled me again. -- hyc */
- int c, n;
- {
- register int i;
- for(i=0;i<n;i++)
- s[i]=c;
- return(s);
- }
- #endif
-
- char *strcpy(), *strcat(), *malloc();
- int strlen(), strcmp(), match();
-
- int
- move(oldnam, newnam)
- char *oldnam, *newnam;
- {
- FILE *fopen(), *old, *new;
- #if !MTS
- struct stat oldstat;
- #endif
- char *strcpy();
- void filecopy();
- #if GEMDOS
- if (Frename(0, oldnam, newnam))
- #else
- if (rename(oldnam, newnam))
- #endif
- #if !MTS
- {
- if (stat(oldnam, &oldstat)) /* different partition? */
- return (-1);
- old = fopen(oldnam, OPEN_R);
- if (old == NULL)
- return (-1);
- new = fopen(newnam, OPEN_W);
- if (new == NULL)
- return (-1);
- filecopy(old, new, oldstat.st_size);
- return(unlink(oldnam));
- }
- return 0;
- #else
- return(-1);
- #endif
- }
-
- static void
- _makefn(source, dest)
- char *source;
- char *dest;
- {
- int j;
- #if MSDOS
- char *setmem();
- #else
- char *memset();
- #endif
-
- setmem(dest, 17, 0); /* clear result field */
- for (j = 0; *source && *source != '.'; ++source)
- if (j < 8)
- dest[j++] = *source;
- for (j = 9; *source; ++source)
- if (j < 13)
- dest[j++] = *source;
- }
- /*
- * make a file name using a template
- */
-
- char *
- makefnam(rawfn, template, result)
- char *rawfn; /* the original file name */
- char *template; /* the template data */
- char *result; /* where to place the result */
- {
- char et[17], er[17], rawbuf[STRLEN], *i, *rindex();
-
- *rawbuf = 0;
- strcpy(rawbuf, rawfn);
- #if MTS
- i = rawbuf;
- if (rawbuf[0] == tmpchr[0]) {
- i++;
- strcpy(rawfn, i);
- } else
- #endif
- if ((i = rindex(rawbuf, CUTOFF))) {
- i++;
- strcpy(rawfn, i);
- }
- #if DOS
- else if ((i = rindex(rawbuf, ':'))) {
- i++;
- strcpy(rawfn, i);
- }
- #endif
- if (i)
- *i = 0;
- else
- *rawbuf = 0;
-
- _makefn(template, et);
- _makefn(rawfn, er);
- *result = 0; /* assure no data */
- strcat(result, rawbuf);
- strcat(result, er[0] ? er : et);
- strcat(result, er[9] ? er + 9 : et + 9);
- return ((char *) &result[0]);
- }
-
- #if MSDOS || SYSV
-
- int
- alphasort(dirptr1, dirptr2)
- struct DIRECT **dirptr1, **dirptr2;
- {
- return (strcmp((*dirptr1)->d_name, (*dirptr2)->d_name));
- }
-
- #endif
-
- void
- upper(string)
- char *string;
- {
- char *p;
-
- for (p = string; *p; p++)
- if (islower(*p))
- *p = toupper(*p);
- }
- /* VARARGS1 */
- void
- abort(s, arg1, arg2, arg3)
- char *s;
- {
- fprintf(stderr, "ARC: ");
- fprintf(stderr, s, arg1, arg2, arg3);
- fprintf(stderr, "\n");
- #if UNIX
- perror("UNIX");
- #endif
- #if GEMDOS
- exitpause();
- #endif
- exit(1);
- }
-
- #if !MTS
-
- char *
- gcdir(dirname)
- char *dirname;
-
- {
- char *getwd();
- #if GEMDOS
- int drv;
- char *buf;
- #endif
- if (dirname == NULL || strlen(dirname) == 0)
- dirname = (char *) malloc(1024);
-
- #if !GEMDOS
- getwd(dirname);
- #else
- buf = dirname;
- *buf++ = (drv = Dgetdrv()) + 'A';
- *buf++ = ':';
- Dgetpath(buf, 0);
- #endif
- return (dirname);
- }
-
- #if UNIX
- char *pattern; /* global so that fmatch can use it */
- #endif
-
- char *
- dir(filename) /* get files, one by one */
- char *filename; /* template, or NULL */
- {
- #if GEMDOS
- static int Nnum = 0;
- static DMABUFFER dbuf, *saved;
- char *name;
-
- if (Nnum == 0) { /* first call */
- saved = (DMABUFFER *) Fgetdta();
- Fsetdta(&dbuf);
- if (Fsfirst(filename, 0) == 0) {
- name = malloc(FNLEN);
- strcpy(name, dbuf.d_fname);
- Nnum++;
- return (name);
- } else {
- Fsetdta(saved);
- return (NULL);
- }
- } else {
- if (Fsnext() == 0) {
- name = malloc(FNLEN);
- strcpy(name, dbuf.d_fname);
- return (name);
- } else {
- Nnum = 0;
- Fsetdta(saved);
- return (NULL);
- }
- }
- }
- #else
- static struct DIRECT **namelist;
- static char **NameList;
- static char namecopy[STRLEN], *dirname;
- #if UNIX
- int alphasort();
- int scandir();
- #endif /* UNIX */
- int fmatch(), free();
- static int Nnum = 0, ii;
- char *rindex();
-
-
- if (Nnum == 0) { /* first call */
- strcpy(namecopy,filename);
- if(pattern=rindex(namecopy,CUTOFF)) {
- *pattern = 0;
- pattern++;
- dirname = namecopy;
- } else {
- pattern = filename;
- dirname = ".";
- }
- Nnum = scandir(dirname, &namelist, fmatch, alphasort);
- NameList = (char **) malloc(Nnum * sizeof(char *));
- for (ii = 0; ii < Nnum; ii++) {
- (NameList)[ii] = malloc(strlen(namelist[ii]->d_name) + 1);
- strcpy((NameList)[ii], namelist[ii]->d_name);
- }
- ii = 0;
- }
- if (ii >= Nnum) { /* all out of files */
- if (Nnum) { /* there were some files found */
- for (ii = 0; ii < Nnum; ii++)
- free(namelist[ii]);
- free(namelist);
- }
- Nnum = 0;
- return (NULL);
- } else {
- return ((NameList)[ii++]);
- }
- }
-
- /*
- * Filename match - here, * matches everything
- */
-
- int
- fmatch(direntry)
- struct DIRECT *direntry;
- {
- char *string;
-
- string = direntry->d_name;
-
- if (!strcmp(pattern, "") || !strcmp(pattern, "*.*") || !strcmp(pattern, "*"))
- return (1);
- return (match(string, pattern));
- }
- #endif /* GEMDOS */
- #else
- /* dir code for MTS under Bell Labs C... */
-
- char *
- dir(filepattern)
- char *filepattern; /* template or NULL */
- {
- char *malloc(), *index();
- #if USECATSCAN
- fortran void catscan(), fileinfo();
-
- struct catname {
- short len;
- char name[257];
- } pattern;
-
- struct catval {
- int maxlen;
- int actlen;
- char name[257];
- } catreturn;
-
- char *i;
- int j, RETCODE;
-
- static int catptr = 0;
- static int catflag = 0x200;
- static int cattype = 1;
- static int patflag = 0;
-
- catreturn.maxlen = 256;
-
- if (patflag) {
- patflag = 0;
- catptr = 0;
- return (NULL);
- }
- if (filepattern) {
- strcpy(pattern.name, filepattern);
- pattern.len = strlen(filepattern);
- if (!index(filepattern, '?'))
- patflag = 1;
- }
- if (patflag) {
- fileinfo(&pattern, &cattype, "CINAME ", &catreturn, _retcode RETCODE);
- catptr = RETCODE ? 0 : 1;
- } else
- catscan(&pattern, &catflag, &cattype, &catreturn, &catptr);
-
- if (!catptr)
- return (NULL);
- else {
- char *k;
-
- k = index(catreturn.name, ' ');
- if (k)
- *k = 0;
- else {
- j = catreturn.actlen;
- catreturn.name[j] = 0;
- }
- k = catreturn.name;
- if (catreturn.name[0] == tmpchr[0])
- k++;
- else if ((k = index(catreturn.name, sepchr[0])))
- k++;
- else
- k = catreturn.name;
- j = strlen(k);
- i = malloc(++j);
- strcpy(i, k);
- return (i);
- }
- #else
- fortran void gfinfo();
- static char gfname[24];
- static char pattern[20];
- static int gfdummy[2] = {
- 0, 0
- }, gfflags;
- int i, RETCODE;
- char *j, *k;
-
- if (filepattern) {
- strcpy(pattern, filepattern);
- strcat(pattern, " ");
- for (i = 20; i < 24; i++)
- gfname[i] = '\0';
- if (index(pattern, '?'))
- gfflags = 0x0C;
- else
- gfflags = 0x09;
- } else if (gfflags == 0x09)
- return (NULL);
-
- gfinfo(pattern, gfname, &gfflags, gfdummy, gfdummy, gfdummy, _retcode RETCODE);
- if (RETCODE)
- return (NULL);
- else {
- k = index(gfname, ' ');
- *k = '\0';
- k = gfname;
- if (gfname[0] == tmpchr[0])
- k++;
- else if ((k = index(gfname, sepchr[0])))
- k++;
- else
- k = gfname;
- i = strlen(k);
- j = malloc(++i);
- strcpy(j, k);
- return (j);
- }
- #endif
- }
-
- int
- unlink(path)
- char *path; /* name of file to delete */
- {
- fortran void destroy();
- int RETCODE;
-
- char name[258];
-
- strcpy(name, path);
- strcat(name, " ");
- destroy(name, _retcode RETCODE);
- if (RETCODE)
- return (-1);
- else
- return (0);
- }
- #endif
- @
-
-
- 1.7
- log
- @Fixed to allow specifying pathnames of target files.
- @
- text
- @d3 1
- a3 1
- * $Header: arcmisc.c,v 1.6 88/06/12 18:47:09 hyc Locked $
- d58 1
- d68 13
- d82 1
- a82 1
- int strlen();
- d89 1
- d91 1
- d93 1
- d99 1
- d103 1
- a103 1
- old = fopen(oldnam, "rb");
- d106 1
- a106 1
- new = fopen(newnam, "wb");
- d110 6
- a115 3
- unlink(oldnam);
- } else
- return 0;
- d124 5
- d183 1
- a183 1
- #if MSDOS
- d292 1
- a292 1
- int fmatch();
- @
-
-
- 1.6
- log
- @Removed 'mode' parameter from dir, since it wasn't used anywhere.
- @
- text
- @d3 1
- a3 1
- * $Header: arcmisc.c,v 1.5 88/06/01 19:41:20 hyc Locked $
- d261 1
- d268 1
- d270 1
- a270 1
- pattern = filename; /* set up for fmatch */
- d272 10
- a281 1
- Nnum = scandir(".", &namelist, fmatch, alphasort);
- @
-
-
- 1.5
- log
- @Changed compilation conditionals
- @
- text
- @d3 1
- a3 1
- * $Header: arcmisc.c,v 1.4 88/06/01 16:06:37 hyc Locked $
- d12 1
- a31 23
- rename(oldnam, newnam)
- char *oldnam, *newnam;
- {
- FILE *fopen(), *old, *new;
- struct stat oldstat;
- char *strcpy();
-
- if (Frename(0, oldnam, newnam)) { /* assume different drive */
- if (stat(oldnam, &oldstat))
- return (-1);
- old = fopen(oldnam, "rb");
- if (old == NULL)
- return (-1);
- new = fopen(newnam, "wb");
- if (new == NULL)
- return (-1);
- filecopy(old, new, oldstat.st_size);
- unlink(oldnam);
- } else
- return 0;
- }
-
- int
- d57 1
- d70 26
- a95 6
- /*
- * char * setmem(dest, size, c) char *dest; unsigned
- * short size; char c; { unsigned short i;
- *
- * for (i = 0; i < size; dest[i] = c, i++); return (&dest[0]); }
- */
- d221 3
- a223 2
- char *pattern; /* global so that fmatch can use them */
- int filemode;
- d226 1
- a226 1
- dir(filename, mode) /* get files, one by one */
- a227 1
- int mode; /* search mode bits */
- d268 1
- a268 2
- pattern = filename;
- filemode = mode; /* set up globals for fmatch */
- d312 1
- a312 1
- dir(filepattern, junk)
- a313 1
- int junk; /* unused on MTS */
- @
-
-
- 1.4
- log
- @Merge Atari ST code
- @
- text
- @d1 5
- d10 1
- a10 1
- #ifdef MSDOS
- d14 1
- a14 1
- #ifdef GEMDOS
- d17 1
- a17 1
- char *index(), *rindex();
- d19 2
- a20 1
- void exitpause()
- d22 6
- a27 6
- while(Cconis())
- Cnecin();
- fprintf(stderr,"Press any key to continue: ");
- fflush(stderr);
- Cnecin();
- fprintf(stderr,"\n");
- d32 1
- a32 1
- char *oldnam, *newnam;
- d34 3
- a36 3
- FILE *fopen(), *old, *new;
- struct stat oldstat;
- char *strcpy();
- d38 13
- a50 12
- if(Frename(0, oldnam, newnam)) { /* assume different drive */
- if(stat(oldnam,&oldstat))
- return(-1);
- old=fopen(oldnam, "rb");
- if (old == NULL)
- return(-1);
- new=fopen(newnam, "wb");
- if (new == NULL)
- return(-1);
- filecopy(old, new, oldstat.st_size);
- unlink(oldnam);
- } else return 0;
- d55 1
- a55 1
- char *dirname;
- d57 2
- a58 2
- char *i;
- int drv;
- d60 13
- a72 13
- i=dirname;
- if ((i=index(dirname,':')) != NULL) {
- drv=i[-1];
- i++; /* Move past device spec */
- if(drv > '\'')
- drv -= 'a';
- else
- drv -= 'A';
- if (drv >= 0 && drv < 16)
- Dsetdrv(drv);
- }
- if (*i != '\0')
- return(Dsetpath(i));
- d76 1
- a76 1
- #ifdef BSD
- d81 1
- a81 1
- #ifdef SYSV
- d88 2
- a89 2
- char *strcpy(), *strcat(), *malloc();
- int strlen();
- d92 4
- a95 2
- * Miscellaneous routines to get ARC running on BSD 4.2...
- * $Header: arcmisc.c,v 1.3 88/06/01 15:54:35 hyc Locked $
- d98 3
- a100 2
- char *
- setmem(dest, size, c)
- a101 2
- unsigned short size;
- char c;
- a102 11
- unsigned short i;
-
- for (i = 0; i < size; dest[i] = c, i++);
- return (&dest[0]);
- }
-
- static void
- _makefn(source, dest)
- char *source;
- char *dest;
- {
- d114 1
- a114 1
- * make a file name using a template
- d119 3
- a121 3
- char *rawfn; /* the original file name */
- char *template; /* the template data */
- char *result; /* where to place the result */
- d123 1
- a123 1
- char et[17], er[17], rawbuf[STRLEN], *i, *rindex();
- d127 1
- a127 1
- #ifdef MTS
- d138 1
- a138 1
- #ifdef DOS
- d158 1
- a158 1
- #if MSDOS
- d179 1
- a179 1
- /*VARARGS1*/
- d187 2
- a188 2
- #ifdef BSD
- perror("BSD");
- d190 1
- a190 1
- #ifdef GEMDOS
- d196 1
- a196 1
- #ifndef MTS
- d203 4
- a206 4
- char *getwd();
- #ifdef GEMDOS
- int drv;
- char *buf;
- d211 1
- a211 1
- #ifndef GEMDOS
- d214 4
- a217 4
- buf=dirname;
- *buf++=(drv=Dgetdrv())+'A';
- *buf++=':';
- Dgetpath(buf,0);
- d219 1
- a219 1
- return(dirname);
- d230 4
- a233 4
- #ifdef GEMDOS
- static int Nnum = 0;
- static DMABUFFER dbuf, *saved;
- char *name;
- d235 23
- a257 26
- if (Nnum == 0) { /* first call */
- saved = (DMABUFFER *)Fgetdta();
- Fsetdta(&dbuf);
- if (Fsfirst(filename, 0) == 0) {
- name = malloc(FNLEN);
- strcpy(name, dbuf.d_fname);
- Nnum++;
- return(name);
- }
- else {
- Fsetdta(saved);
- return(NULL);
- }
- }
- else {
- if (Fsnext() == 0) {
- name = malloc(FNLEN);
- strcpy(name, dbuf.d_fname);
- return(name);
- }
- else {
- Nnum=0;
- Fsetdta(saved);
- return(NULL);
- }
- }
- d262 1
- a262 1
- #ifdef BSD
- d265 1
- a265 1
- #endif /* BSD */
- d294 1
- a294 1
- * Filename match - here, * matches everything
- d309 1
- a309 1
- #endif /* GEMDOS */
- d319 2
- a320 2
- #ifdef USECATSCAN
- fortran catscan(), fileinfo();
- d385 1
- a385 1
- fortran gfinfo();
- d431 2
- a432 2
- fortran destroy();
- int RETCODE;
- @
-
-
- 1.3
- log
- @Fix declarations
- @
- text
- @d9 60
- d86 1
- a86 1
- * $Header: arcmisc.c,v 1.9 88/04/19 01:40:05 hyc Exp $
- a100 10
- #ifdef MTS
- #define CUTOFF sepchr[0]
- #endif
- #ifdef MSDOS
- #define CUTOFF '\\'
- #endif
- #ifdef BSD
- #define CUTOFF '/'
- #endif
-
- d141 1
- a141 1
- #ifdef MSDOS
- d178 1
- a178 1
- for (p = string; *p != NULL; p++)
- d193 3
- d207 4
- d214 1
- d216 6
- d233 33
- d315 1
- @
-
-
- 1.2
- log
- @re-synch with MTS, changes for CBELL to C87...
- @
- text
- @d4 1
- d8 1
- d14 6
- a19 1
- /* Miscellaneous routines to get ARC running on BSD 4.2... */
- d21 2
- d24 5
- d32 1
- a32 1
- unsigned INT size;
- d35 1
- a35 1
- unsigned INT i;
- d51 1
- a51 1
- static INT
- d53 2
- a54 2
- unsigned char *source;
- unsigned char *dest;
- d56 1
- a56 1
- INT j;
- d72 3
- a74 3
- unsigned char *rawfn; /* the original file name */
- unsigned char *template; /* the template data */
- unsigned char *result; /* where to place the result */
- d76 1
- a76 1
- unsigned char et[17], er[17], rawbuf[100], *i, *rindex();
- d113 1
- a113 1
- INT
- d115 1
- a115 1
- struct direct **dirptr1, **dirptr2;
- d122 1
- a122 1
- INT
- d132 2
- a133 1
- INT
- d153 1
- d158 1
- d162 1
- a162 1
- INT filemode;
- d167 1
- a167 1
- INT mode; /* search mode bits */
- d169 1
- a169 1
- static struct direct **namelist;
- d176 1
- a176 2
- static INT Nnum = 0, ii;
- char *result = NULL;
- d184 1
- a184 1
- (NameList)[ii] = (char *) malloc(namelist[ii]->d_namlen + 1);
- a201 20
-
- #define ASTERISK '*' /* The '*' metacharacter */
- #define QUESTION '?' /* The '?' metacharacter */
- #define LEFT_BRACKET '[' /* The '[' metacharacter */
- #define RIGHT_BRACKET ']' /* The ']' metacharacter */
-
- #define IS_OCTAL(ch) (ch >= '0' && ch <= '7')
-
- typedef INT BOOLEAN;
- #define VOID short
- #define TRUE 1
- #define FALSE 0
- #define EOS '\000'
-
- static BOOLEAN do_list();
- static char nextch();
- static VOID list_parse();
-
-
-
- a202 180
- * FUNCTION
- *
- * do_list process a list and following substring
- *
- * SYNOPSIS
- *
- * static BOOLEAN do_list (string, pattern) register char *string; register char
- * *pattern;
- *
- * DESCRIPTION
- *
- * Called when a list is found in the pattern. Returns TRUE if the current
- * character matches the list and the remaining substring matches the
- * remaining pattern.
- *
- * Returns FALSE if either the current character fails to match the list or the
- * list matches but the remaining substring and subpattern's don't.
- *
- * RESTRICTIONS
- *
- * The mechanism used to match characters in an inclusive pair (I.E. [a-d]) may
- * not be portable to machines in which the native character set is not
- * ASCII.
- *
- * The rules implemented here are:
- *
- * (1) The backslash character may be used to quote any special character.
- * I.E. "\]" and "\-" anywhere in list, or "\!" at start of list.
- *
- * (2) The sequence \nnn becomes the character given by nnn (in octal).
- *
- * (3) Any non-escaped ']' marks the end of list.
- *
- * (4) A list beginning with the special character '!' matches any character
- * NOT in list. The '!' character is only special if it is the first
- * character in the list.
- *
- */
-
-
-
- /*
- * PSEUDO CODE
- *
- * Begin do_list Default result is no match Skip over the opening left bracket
- * If the next pattern character is a '!' then List match gives FALSE Skip
- * over the '!' character Else List match gives TRUE End if While not at
- * closing bracket or EOS Get lower and upper bounds If character in bounds
- * then Result is same as sense flag. Skip over rest of list End if End while
- * If match found then If not at end of pattern then Call match with rest of
- * pattern End if End if Return match result End do_list
- *
- */
-
- static BOOLEAN
- do_list(string, pattern)
- register char *string;
- char *pattern;
- {
- register BOOLEAN ismatch;
- register BOOLEAN if_found;
- register BOOLEAN if_not_found;
- auto char lower;
- auto char upper;
-
- pattern++;
- if (*pattern == '!') {
- if_found = FALSE;
- if_not_found = TRUE;
- pattern++;
- } else {
- if_found = TRUE;
- if_not_found = FALSE;
- }
- ismatch = if_not_found;
- while (*pattern != ']' && *pattern != EOS) {
- list_parse(&pattern, &lower, &upper);
- if (*string >= lower && *string <= upper) {
- ismatch = if_found;
- while (*pattern != ']' && *pattern != EOS) {
- pattern++;
- }
- }
- }
- if (*pattern++ != ']') {
- fprintf(stderr, "warning - character class error\n");
- } else {
- if (ismatch) {
- ismatch = match(++string, pattern);
- }
- }
- return (ismatch);
- }
-
-
-
- /*
- * FUNCTION
- *
- * list_parse parse part of list into lower and upper bounds
- *
- * SYNOPSIS
- *
- * static VOID list_parse (patp, lowp, highp) char **patp; char *lowp; char
- * *highp;
- *
- * DESCRIPTION
- *
- * Given pointer to a pattern pointer (patp), pointer to a place to store lower
- * bound (lowp), and pointer to a place to store upper bound (highp), parses
- * part of the list, updating the pattern pointer in the process.
- *
- * For list characters which are not part of a range, the lower and upper bounds
- * are set to that character.
- *
- */
-
- static VOID
- list_parse(patp, lowp, highp)
- char **patp;
- char *lowp;
- char *highp;
- {
- *lowp = nextch(patp);
- if (**patp == '-') {
- (*patp)++;
- *highp = nextch(patp);
- } else {
- *highp = *lowp;
- }
- }
-
-
-
- /*
- * FUNCTION
- *
- * nextch determine next character in a pattern
- *
- * SYNOPSIS
- *
- * static char nextch (patp) char **patp;
- *
- * DESCRIPTION
- *
- * Given pointer to a pointer to a pattern, uses the pattern pointer to
- * determine the next character in the pattern, subject to translation of
- * backslash-char and backslash-octal sequences.
- *
- * The character pointer is updated to point at the next pattern character to be
- * processed.
- *
- */
-
- static char
- nextch(patp)
- char **patp;
- {
- register char ch;
- register char chsum;
- register INT count;
-
- ch = *(*patp)++;
- if (ch == '\\') {
- ch = *(*patp)++;
- if (IS_OCTAL(ch)) {
- chsum = 0;
- for (count = 0; count < 3 && IS_OCTAL(ch); count++) {
- chsum *= 8;
- chsum += ch - '0';
- ch = *(*patp)++;
- }
- (*patp)--;
- ch = chsum;
- }
- }
- return (ch);
- }
-
- /*
- d208 1
- a208 1
- struct direct *direntry;
- d210 1
- a210 1
- char *ptr, *string;
- d224 1
- a224 1
- INT junk; /* unused on MTS */
- d335 1
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d17 3
- a19 2
- char *dest, c;
- INT size;
- d21 1
- a21 1
- INT i;
- d157 1
- a157 1
- #endif BSD
- d426 1
- a426 1
- int j;
- d447 1
- a447 1
- fileinfo(&pattern, &cattype, "CINAME ", &catreturn);
- d483 1
- a483 1
- int i;
- d498 1
- a498 1
- gfinfo(pattern, gfname, &gfflags, gfdummy, gfdummy, gfdummy);
- d523 1
- d529 1
- a529 1
- destroy(name);
- @
-